﻿
using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using DBUtility;

namespace XQ.SP.DalServices
{
    //用户
    public partial class UsersDal : BaseDal
    {

        public bool ExistsWhere(string whereSql)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from Users");
            if (whereSql != "")
            {
                strSql.Append(" where " + whereSql);
            }

            return DbHelperSQL.Exists(strSql.ToString());
        }
        public bool Exists(long id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from [Users]");
            strSql.Append(" where  [Id]=@Id ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
            parameters[0].Value = id;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }



        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(XQ.SP.Model.UsersItem model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [Users](");
            strSql.Append("[UserName],[NO],[Email],[IDCard],[Mobil],[RealName],[UserPassword],[Telephone],[QQ],[Sex],[Birthday],[Address],[Description],[PhotoPath],[CreateTime],[UpLoginTime],[Integral],[Degree],[Attest],[PostsCount],[PostsSaidCount],[GoodSaidCount],[WeiXin],[UsefulCount],[UMoney],[UserType],[Status],[Creator],[Created],[Modifier],[Modified],[StuNo],[SelfID],[ClassName],[RolesId],[Roles],[DepaId],[DepaName],[ImagesBlog],[GoodCount],[ParentId],[SysDegreeId],[SysDegreeName]");
            strSql.Append(") values (");
                strSql.Append("@UserName,@NO,@Email,@IDCard,@Mobil,@RealName,@UserPassword,@Telephone,@QQ,@Sex,@Birthday,@Address,@Description,@PhotoPath,@CreateTime,@UpLoginTime,@Integral,@Degree,@Attest,@PostsCount,@PostsSaidCount,@GoodSaidCount,@WeiXin,@UsefulCount,@UMoney,@UserType,@Status,@Creator,@Created,@Modifier,@Modified,@StuNo,@SelfID,@ClassName,@RolesId,@Roles,@DepaId,@DepaName,@ImagesBlog,@GoodCount,@ParentId,@SysDegreeId,@SysDegreeName");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@UserName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@NO", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Email", SqlDbType.NVarChar,160) ,            
			            new SqlParameter("@IDCard", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Mobil", SqlDbType.NVarChar,30) ,            
			            new SqlParameter("@RealName", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@UserPassword", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Telephone", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@QQ", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,20) ,            
			            new SqlParameter("@Birthday", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Address", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Description", SqlDbType.NVarChar,2000) ,            
			            new SqlParameter("@PhotoPath", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@CreateTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@UpLoginTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Integral", SqlDbType.Int,4) ,            
			            new SqlParameter("@Degree", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Attest", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@WeiXin", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@UMoney", SqlDbType.Int,4) ,            
			            new SqlParameter("@UserType", SqlDbType.Int,4) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@StuNo", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@SelfID", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ClassName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@RolesId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Roles", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@DepaId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@DepaName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ImagesBlog", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@GoodCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeName", SqlDbType.NVarChar,80) ,            
            };
            
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.NO;
            parameters[2].Value = model.Email;
            parameters[3].Value = model.IDCard;
            parameters[4].Value = model.Mobil;
            parameters[5].Value = model.RealName;
            parameters[6].Value = model.UserPassword;
            parameters[7].Value = model.Telephone;
            parameters[8].Value = model.QQ;
            parameters[9].Value = model.Sex;
            parameters[10].Value = model.Birthday;
            parameters[11].Value = model.Address;
            parameters[12].Value = model.Description;
            parameters[13].Value = model.PhotoPath;
            parameters[14].Value = model.CreateTime;
            parameters[15].Value = model.UpLoginTime;
            parameters[16].Value = model.Integral;
            parameters[17].Value = model.Degree;
            parameters[18].Value = model.Attest;
            parameters[19].Value = model.PostsCount;
            parameters[20].Value = model.PostsSaidCount;
            parameters[21].Value = model.GoodSaidCount;
            parameters[22].Value = model.WeiXin;
            parameters[23].Value = model.UsefulCount;
            parameters[24].Value = model.UMoney;
            parameters[25].Value = model.UserType;
            parameters[26].Value = model.Status;
            parameters[27].Value = model.Creator;
            parameters[28].Value = model.Created;
            parameters[29].Value = model.Modifier;
            parameters[30].Value = model.Modified;
            parameters[31].Value = model.StuNo;
            parameters[32].Value = model.SelfID;
            parameters[33].Value = model.ClassName;
            parameters[34].Value = model.RolesId;
            parameters[35].Value = model.Roles;
            parameters[36].Value = model.DepaId;
            parameters[37].Value = model.DepaName;
            parameters[38].Value = model.ImagesBlog;
            parameters[39].Value = model.GoodCount;
            parameters[40].Value = model.ParentId;
            parameters[41].Value = model.SysDegreeId;
            parameters[42].Value = model.SysDegreeName;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt64(obj);
            }

        }

        /// <summary>
        ///   批量添加数据
        /// </summary>
        public int AddList(List<XQ.SP.Model.UsersItem> models)
        {
            List<CommandInfo> commands = new List<CommandInfo>();
            foreach (XQ.SP.Model.UsersItem model in models)
            {
                CommandInfo command = new CommandInfo();
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into [Users](");
                strSql.Append("[UserName],[NO],[Email],[IDCard],[Mobil],[RealName],[UserPassword],[Telephone],[QQ],[Sex],[Birthday],[Address],[Description],[PhotoPath],[CreateTime],[UpLoginTime],[Integral],[Degree],[Attest],[PostsCount],[PostsSaidCount],[GoodSaidCount],[WeiXin],[UsefulCount],[UMoney],[UserType],[Status],[Creator],[Created],[Modifier],[Modified],[StuNo],[SelfID],[ClassName],[RolesId],[Roles],[DepaId],[DepaName],[ImagesBlog],[GoodCount],[ParentId],[SysDegreeId],[SysDegreeName]");
                strSql.Append(") values (");
                strSql.Append("@UserName,@NO,@Email,@IDCard,@Mobil,@RealName,@UserPassword,@Telephone,@QQ,@Sex,@Birthday,@Address,@Description,@PhotoPath,@CreateTime,@UpLoginTime,@Integral,@Degree,@Attest,@PostsCount,@PostsSaidCount,@GoodSaidCount,@WeiXin,@UsefulCount,@UMoney,@UserType,@Status,@Creator,@Created,@Modifier,@Modified,@StuNo,@SelfID,@ClassName,@RolesId,@Roles,@DepaId,@DepaName,@ImagesBlog,@GoodCount,@ParentId,@SysDegreeId,@SysDegreeName");
                strSql.Append(") ");
                strSql.Append(";select @@IDENTITY");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@UserName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@NO", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Email", SqlDbType.NVarChar,160) ,            
			            new SqlParameter("@IDCard", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Mobil", SqlDbType.NVarChar,30) ,            
			            new SqlParameter("@RealName", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@UserPassword", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Telephone", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@QQ", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,20) ,            
			            new SqlParameter("@Birthday", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Address", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Description", SqlDbType.NVarChar,2000) ,            
			            new SqlParameter("@PhotoPath", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@CreateTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@UpLoginTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Integral", SqlDbType.Int,4) ,            
			            new SqlParameter("@Degree", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Attest", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@WeiXin", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@UMoney", SqlDbType.Int,4) ,            
			            new SqlParameter("@UserType", SqlDbType.Int,4) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@StuNo", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@SelfID", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ClassName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@RolesId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Roles", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@DepaId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@DepaName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ImagesBlog", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@GoodCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeName", SqlDbType.NVarChar,80) ,            
            };
            
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.NO;
            parameters[2].Value = model.Email;
            parameters[3].Value = model.IDCard;
            parameters[4].Value = model.Mobil;
            parameters[5].Value = model.RealName;
            parameters[6].Value = model.UserPassword;
            parameters[7].Value = model.Telephone;
            parameters[8].Value = model.QQ;
            parameters[9].Value = model.Sex;
            parameters[10].Value = model.Birthday;
            parameters[11].Value = model.Address;
            parameters[12].Value = model.Description;
            parameters[13].Value = model.PhotoPath;
            parameters[14].Value = model.CreateTime;
            parameters[15].Value = model.UpLoginTime;
            parameters[16].Value = model.Integral;
            parameters[17].Value = model.Degree;
            parameters[18].Value = model.Attest;
            parameters[19].Value = model.PostsCount;
            parameters[20].Value = model.PostsSaidCount;
            parameters[21].Value = model.GoodSaidCount;
            parameters[22].Value = model.WeiXin;
            parameters[23].Value = model.UsefulCount;
            parameters[24].Value = model.UMoney;
            parameters[25].Value = model.UserType;
            parameters[26].Value = model.Status;
            parameters[27].Value = model.Creator;
            parameters[28].Value = model.Created;
            parameters[29].Value = model.Modifier;
            parameters[30].Value = model.Modified;
            parameters[31].Value = model.StuNo;
            parameters[32].Value = model.SelfID;
            parameters[33].Value = model.ClassName;
            parameters[34].Value = model.RolesId;
            parameters[35].Value = model.Roles;
            parameters[36].Value = model.DepaId;
            parameters[37].Value = model.DepaName;
            parameters[38].Value = model.ImagesBlog;
            parameters[39].Value = model.GoodCount;
            parameters[40].Value = model.ParentId;
            parameters[41].Value = model.SysDegreeId;
            parameters[42].Value = model.SysDegreeName;
                command.CommandText = strSql.ToString();
                command.Parameters = parameters;
                commands.Add(command);
            }
            object obj = DbHelperSQL.ExecuteSqlTran(commands);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }


        /// <summary>
        /// 批量更新数据
        /// </summary>
        public int UpdateList(List<XQ.SP.Model.UsersItem> models)
        {
            List<CommandInfo> commands = new List<CommandInfo>();
            CommandInfo command = new CommandInfo();

            foreach (XQ.SP.Model.UsersItem model in models)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update [Users] set ");
            
                strSql.Append(" [UserName] = @UserName,");
                strSql.Append(" [NO] = @NO,");
                strSql.Append(" [Email] = @Email,");
                strSql.Append(" [IDCard] = @IDCard,");
                strSql.Append(" [Mobil] = @Mobil,");
                strSql.Append(" [RealName] = @RealName,");
                strSql.Append(" [UserPassword] = @UserPassword,");
                strSql.Append(" [Telephone] = @Telephone,");
                strSql.Append(" [QQ] = @QQ,");
                strSql.Append(" [Sex] = @Sex,");
                strSql.Append(" [Birthday] = @Birthday,");
                strSql.Append(" [Address] = @Address,");
                strSql.Append(" [Description] = @Description,");
                strSql.Append(" [PhotoPath] = @PhotoPath,");
                strSql.Append(" [CreateTime] = @CreateTime,");
                strSql.Append(" [UpLoginTime] = @UpLoginTime,");
                strSql.Append(" [Integral] = @Integral,");
                strSql.Append(" [Degree] = @Degree,");
                strSql.Append(" [Attest] = @Attest,");
                strSql.Append(" [PostsCount] = @PostsCount,");
                strSql.Append(" [PostsSaidCount] = @PostsSaidCount,");
                strSql.Append(" [GoodSaidCount] = @GoodSaidCount,");
                strSql.Append(" [WeiXin] = @WeiXin,");
                strSql.Append(" [UsefulCount] = @UsefulCount,");
                strSql.Append(" [UMoney] = @UMoney,");
                strSql.Append(" [UserType] = @UserType,");
                strSql.Append(" [Status] = @Status,");
                strSql.Append(" [Creator] = @Creator,");
                strSql.Append(" [Created] = @Created,");
                strSql.Append(" [Modifier] = @Modifier,");
                strSql.Append(" [Modified] = @Modified,");
                strSql.Append(" [StuNo] = @StuNo,");
                strSql.Append(" [SelfID] = @SelfID,");
                strSql.Append(" [ClassName] = @ClassName,");
                strSql.Append(" [RolesId] = @RolesId,");
                strSql.Append(" [Roles] = @Roles,");
                strSql.Append(" [DepaId] = @DepaId,");
                strSql.Append(" [DepaName] = @DepaName,");
                strSql.Append(" [ImagesBlog] = @ImagesBlog,");
                strSql.Append(" [GoodCount] = @GoodCount,");
                strSql.Append(" [ParentId] = @ParentId,");
                strSql.Append(" [SysDegreeId] = @SysDegreeId,");
                strSql.Append(" [SysDegreeName] = @SysDegreeName");
                strSql.Append(" where [Id]=@Id ");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@UserName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@NO", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Email", SqlDbType.NVarChar,160) ,            
			            new SqlParameter("@IDCard", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Mobil", SqlDbType.NVarChar,30) ,            
			            new SqlParameter("@RealName", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@UserPassword", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Telephone", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@QQ", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,20) ,            
			            new SqlParameter("@Birthday", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Address", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Description", SqlDbType.NVarChar,2000) ,            
			            new SqlParameter("@PhotoPath", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@CreateTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@UpLoginTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Integral", SqlDbType.Int,4) ,            
			            new SqlParameter("@Degree", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Attest", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@WeiXin", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@UMoney", SqlDbType.Int,4) ,            
			            new SqlParameter("@UserType", SqlDbType.Int,4) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@StuNo", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@SelfID", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ClassName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@RolesId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Roles", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@DepaId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@DepaName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ImagesBlog", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@GoodCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeName", SqlDbType.NVarChar,80) ,            
            };
            
            parameters[0].Value = model.Id;
            parameters[1].Value = model.UserName;
            parameters[2].Value = model.NO;
            parameters[3].Value = model.Email;
            parameters[4].Value = model.IDCard;
            parameters[5].Value = model.Mobil;
            parameters[6].Value = model.RealName;
            parameters[7].Value = model.UserPassword;
            parameters[8].Value = model.Telephone;
            parameters[9].Value = model.QQ;
            parameters[10].Value = model.Sex;
            parameters[11].Value = model.Birthday;
            parameters[12].Value = model.Address;
            parameters[13].Value = model.Description;
            parameters[14].Value = model.PhotoPath;
            parameters[15].Value = model.CreateTime;
            parameters[16].Value = model.UpLoginTime;
            parameters[17].Value = model.Integral;
            parameters[18].Value = model.Degree;
            parameters[19].Value = model.Attest;
            parameters[20].Value = model.PostsCount;
            parameters[21].Value = model.PostsSaidCount;
            parameters[22].Value = model.GoodSaidCount;
            parameters[23].Value = model.WeiXin;
            parameters[24].Value = model.UsefulCount;
            parameters[25].Value = model.UMoney;
            parameters[26].Value = model.UserType;
            parameters[27].Value = model.Status;
            parameters[28].Value = model.Creator;
            parameters[29].Value = model.Created;
            parameters[30].Value = model.Modifier;
            parameters[31].Value = model.Modified;
            parameters[32].Value = model.StuNo;
            parameters[33].Value = model.SelfID;
            parameters[34].Value = model.ClassName;
            parameters[35].Value = model.RolesId;
            parameters[36].Value = model.Roles;
            parameters[37].Value = model.DepaId;
            parameters[38].Value = model.DepaName;
            parameters[39].Value = model.ImagesBlog;
            parameters[40].Value = model.GoodCount;
            parameters[41].Value = model.ParentId;
            parameters[42].Value = model.SysDegreeId;
            parameters[43].Value = model.SysDegreeName;
                command.CommandText = strSql.ToString();
                command.Parameters = parameters;
                commands.Add(command);
            }

            int rows = DbHelperSQL.ExecuteSqlTran(commands);
            return rows;

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XQ.SP.Model.UsersItem model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update [Users] set ");
            
                strSql.Append(" [UserName] = @UserName,");
                strSql.Append(" [NO] = @NO,");
                strSql.Append(" [Email] = @Email,");
                strSql.Append(" [IDCard] = @IDCard,");
                strSql.Append(" [Mobil] = @Mobil,");
                strSql.Append(" [RealName] = @RealName,");
                strSql.Append(" [UserPassword] = @UserPassword,");
                strSql.Append(" [Telephone] = @Telephone,");
                strSql.Append(" [QQ] = @QQ,");
                strSql.Append(" [Sex] = @Sex,");
                strSql.Append(" [Birthday] = @Birthday,");
                strSql.Append(" [Address] = @Address,");
                strSql.Append(" [Description] = @Description,");
                strSql.Append(" [PhotoPath] = @PhotoPath,");
                strSql.Append(" [CreateTime] = @CreateTime,");
                strSql.Append(" [UpLoginTime] = @UpLoginTime,");
                strSql.Append(" [Integral] = @Integral,");
                strSql.Append(" [Degree] = @Degree,");
                strSql.Append(" [Attest] = @Attest,");
                strSql.Append(" [PostsCount] = @PostsCount,");
                strSql.Append(" [PostsSaidCount] = @PostsSaidCount,");
                strSql.Append(" [GoodSaidCount] = @GoodSaidCount,");
                strSql.Append(" [WeiXin] = @WeiXin,");
                strSql.Append(" [UsefulCount] = @UsefulCount,");
                strSql.Append(" [UMoney] = @UMoney,");
                strSql.Append(" [UserType] = @UserType,");
                strSql.Append(" [Status] = @Status,");
                strSql.Append(" [Creator] = @Creator,");
                strSql.Append(" [Created] = @Created,");
                strSql.Append(" [Modifier] = @Modifier,");
                strSql.Append(" [Modified] = @Modified,");
                strSql.Append(" [StuNo] = @StuNo,");
                strSql.Append(" [SelfID] = @SelfID,");
                strSql.Append(" [ClassName] = @ClassName,");
                strSql.Append(" [RolesId] = @RolesId,");
                strSql.Append(" [Roles] = @Roles,");
                strSql.Append(" [DepaId] = @DepaId,");
                strSql.Append(" [DepaName] = @DepaName,");
                strSql.Append(" [ImagesBlog] = @ImagesBlog,");
                strSql.Append(" [GoodCount] = @GoodCount,");
                strSql.Append(" [ParentId] = @ParentId,");
                strSql.Append(" [SysDegreeId] = @SysDegreeId,");
                strSql.Append(" [SysDegreeName] = @SysDegreeName");
                strSql.Append(" where [Id]=@Id ");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@UserName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@NO", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Email", SqlDbType.NVarChar,160) ,            
			            new SqlParameter("@IDCard", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Mobil", SqlDbType.NVarChar,30) ,            
			            new SqlParameter("@RealName", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@UserPassword", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@Telephone", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@QQ", SqlDbType.NVarChar,40) ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,20) ,            
			            new SqlParameter("@Birthday", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Address", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Description", SqlDbType.NVarChar,2000) ,            
			            new SqlParameter("@PhotoPath", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@CreateTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@UpLoginTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Integral", SqlDbType.Int,4) ,            
			            new SqlParameter("@Degree", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@Attest", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@PostsSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@GoodSaidCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@WeiXin", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@UsefulCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@UMoney", SqlDbType.Int,4) ,            
			            new SqlParameter("@UserType", SqlDbType.Int,4) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@StuNo", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@SelfID", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ClassName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@RolesId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Roles", SqlDbType.NVarChar,200) ,            
			            new SqlParameter("@DepaId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@DepaName", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@ImagesBlog", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@GoodCount", SqlDbType.Int,4) ,            
			            new SqlParameter("@ParentId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysDegreeName", SqlDbType.NVarChar,80) ,            
            };
            
            parameters[0].Value = model.Id;
            parameters[1].Value = model.UserName;
            parameters[2].Value = model.NO;
            parameters[3].Value = model.Email;
            parameters[4].Value = model.IDCard;
            parameters[5].Value = model.Mobil;
            parameters[6].Value = model.RealName;
            parameters[7].Value = model.UserPassword;
            parameters[8].Value = model.Telephone;
            parameters[9].Value = model.QQ;
            parameters[10].Value = model.Sex;
            parameters[11].Value = model.Birthday;
            parameters[12].Value = model.Address;
            parameters[13].Value = model.Description;
            parameters[14].Value = model.PhotoPath;
            parameters[15].Value = model.CreateTime;
            parameters[16].Value = model.UpLoginTime;
            parameters[17].Value = model.Integral;
            parameters[18].Value = model.Degree;
            parameters[19].Value = model.Attest;
            parameters[20].Value = model.PostsCount;
            parameters[21].Value = model.PostsSaidCount;
            parameters[22].Value = model.GoodSaidCount;
            parameters[23].Value = model.WeiXin;
            parameters[24].Value = model.UsefulCount;
            parameters[25].Value = model.UMoney;
            parameters[26].Value = model.UserType;
            parameters[27].Value = model.Status;
            parameters[28].Value = model.Creator;
            parameters[29].Value = model.Created;
            parameters[30].Value = model.Modifier;
            parameters[31].Value = model.Modified;
            parameters[32].Value = model.StuNo;
            parameters[33].Value = model.SelfID;
            parameters[34].Value = model.ClassName;
            parameters[35].Value = model.RolesId;
            parameters[36].Value = model.Roles;
            parameters[37].Value = model.DepaId;
            parameters[38].Value = model.DepaName;
            parameters[39].Value = model.ImagesBlog;
            parameters[40].Value = model.GoodCount;
            parameters[41].Value = model.ParentId;
            parameters[42].Value = model.SysDegreeId;
            parameters[43].Value = model.SysDegreeName;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }



        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(long Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from Users ");
            strSql.Append(" where Id=@Id  ");
            SqlParameter[] parameters = {new SqlParameter("@Id", SqlDbType.BigInt)};
            parameters[0].Value = Id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string Idlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from Users ");
            strSql.Append(" where Id in (" + Idlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XQ.SP.Model.UsersItem GetModel(long Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *  ");
            strSql.Append("  from Users ");
            strSql.Append(" where Id=@Id  ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
            parameters[0].Value = Id;


            XQ.SP.Model.UsersItem model = new XQ.SP.Model.UsersItem();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = Int64.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserName"].ToString() != "")
                {
                    model.UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["NO"].ToString() != "")
                {
                    model.NO = ds.Tables[0].Rows[0]["NO"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Email"].ToString() != "")
                {
                    model.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IDCard"].ToString() != "")
                {
                    model.IDCard = ds.Tables[0].Rows[0]["IDCard"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Mobil"].ToString() != "")
                {
                    model.Mobil = ds.Tables[0].Rows[0]["Mobil"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RealName"].ToString() != "")
                {
                    model.RealName = ds.Tables[0].Rows[0]["RealName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UserPassword"].ToString() != "")
                {
                    model.UserPassword = ds.Tables[0].Rows[0]["UserPassword"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Telephone"].ToString() != "")
                {
                    model.Telephone = ds.Tables[0].Rows[0]["Telephone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["QQ"].ToString() != "")
                {
                    model.QQ = ds.Tables[0].Rows[0]["QQ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Birthday"].ToString() != "")
                {
                    model.Birthday = System.DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Address"].ToString() != "")
                {
                    model.Address = ds.Tables[0].Rows[0]["Address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Description"].ToString() != "")
                {
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PhotoPath"].ToString() != "")
                {
                    model.PhotoPath = ds.Tables[0].Rows[0]["PhotoPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UpLoginTime"].ToString() != "")
                {
                    model.UpLoginTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["UpLoginTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Integral"].ToString() != "")
                {
                    model.Integral = Int32.Parse(ds.Tables[0].Rows[0]["Integral"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Degree"].ToString() != "")
                {
                    model.Degree = ds.Tables[0].Rows[0]["Degree"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Attest"].ToString() != "")
                {
                    model.Attest = Int32.Parse(ds.Tables[0].Rows[0]["Attest"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PostsCount"].ToString() != "")
                {
                    model.PostsCount = Int32.Parse(ds.Tables[0].Rows[0]["PostsCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PostsSaidCount"].ToString() != "")
                {
                    model.PostsSaidCount = Int32.Parse(ds.Tables[0].Rows[0]["PostsSaidCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["GoodSaidCount"].ToString() != "")
                {
                    model.GoodSaidCount = Int32.Parse(ds.Tables[0].Rows[0]["GoodSaidCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WeiXin"].ToString() != "")
                {
                    model.WeiXin = ds.Tables[0].Rows[0]["WeiXin"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UsefulCount"].ToString() != "")
                {
                    model.UsefulCount = Int32.Parse(ds.Tables[0].Rows[0]["UsefulCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UMoney"].ToString() != "")
                {
                    model.UMoney = Int32.Parse(ds.Tables[0].Rows[0]["UMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserType"].ToString() != "")
                {
                    model.UserType = Int32.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = Int32.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Creator"].ToString() != "")
                {
                    model.Creator = Int64.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Created"].ToString() != "")
                {
                    model.Created = System.DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modifier"].ToString() != "")
                {
                    model.Modifier = Int64.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modified"].ToString() != "")
                {
                    model.Modified = System.DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StuNo"].ToString() != "")
                {
                    model.StuNo = ds.Tables[0].Rows[0]["StuNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SelfID"].ToString() != "")
                {
                    model.SelfID = ds.Tables[0].Rows[0]["SelfID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ClassName"].ToString() != "")
                {
                    model.ClassName = ds.Tables[0].Rows[0]["ClassName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RolesId"].ToString() != "")
                {
                    model.RolesId = Int64.Parse(ds.Tables[0].Rows[0]["RolesId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Roles"].ToString() != "")
                {
                    model.Roles = ds.Tables[0].Rows[0]["Roles"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DepaId"].ToString() != "")
                {
                    model.DepaId = Int64.Parse(ds.Tables[0].Rows[0]["DepaId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DepaName"].ToString() != "")
                {
                    model.DepaName = ds.Tables[0].Rows[0]["DepaName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ImagesBlog"].ToString() != "")
                {
                    model.ImagesBlog = ds.Tables[0].Rows[0]["ImagesBlog"].ToString();
                }
                if (ds.Tables[0].Rows[0]["GoodCount"].ToString() != "")
                {
                    model.GoodCount = Int32.Parse(ds.Tables[0].Rows[0]["GoodCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ParentId"].ToString() != "")
                {
                    model.ParentId = Int64.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SysDegreeId"].ToString() != "")
                {
                    model.SysDegreeId = Int64.Parse(ds.Tables[0].Rows[0]["SysDegreeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SysDegreeName"].ToString() != "")
                {
                    model.SysDegreeName = ds.Tables[0].Rows[0]["SysDegreeName"].ToString();
                }

                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XQ.SP.Model.UsersItem GetModelWhereStr(string whereStr)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *  ");
            strSql.Append("  from Users ");
            if (whereStr != "")
            {
                strSql.Append(" where " + whereStr);
            }

            XQ.SP.Model.UsersItem model = new XQ.SP.Model.UsersItem();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = Int64.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserName"].ToString() != "")
                {
                    model.UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["NO"].ToString() != "")
                {
                    model.NO = ds.Tables[0].Rows[0]["NO"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Email"].ToString() != "")
                {
                    model.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IDCard"].ToString() != "")
                {
                    model.IDCard = ds.Tables[0].Rows[0]["IDCard"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Mobil"].ToString() != "")
                {
                    model.Mobil = ds.Tables[0].Rows[0]["Mobil"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RealName"].ToString() != "")
                {
                    model.RealName = ds.Tables[0].Rows[0]["RealName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UserPassword"].ToString() != "")
                {
                    model.UserPassword = ds.Tables[0].Rows[0]["UserPassword"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Telephone"].ToString() != "")
                {
                    model.Telephone = ds.Tables[0].Rows[0]["Telephone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["QQ"].ToString() != "")
                {
                    model.QQ = ds.Tables[0].Rows[0]["QQ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Birthday"].ToString() != "")
                {
                    model.Birthday = System.DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Address"].ToString() != "")
                {
                    model.Address = ds.Tables[0].Rows[0]["Address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Description"].ToString() != "")
                {
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PhotoPath"].ToString() != "")
                {
                    model.PhotoPath = ds.Tables[0].Rows[0]["PhotoPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UpLoginTime"].ToString() != "")
                {
                    model.UpLoginTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["UpLoginTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Integral"].ToString() != "")
                {
                    model.Integral = Int32.Parse(ds.Tables[0].Rows[0]["Integral"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Degree"].ToString() != "")
                {
                    model.Degree = ds.Tables[0].Rows[0]["Degree"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Attest"].ToString() != "")
                {
                    model.Attest = Int32.Parse(ds.Tables[0].Rows[0]["Attest"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PostsCount"].ToString() != "")
                {
                    model.PostsCount = Int32.Parse(ds.Tables[0].Rows[0]["PostsCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PostsSaidCount"].ToString() != "")
                {
                    model.PostsSaidCount = Int32.Parse(ds.Tables[0].Rows[0]["PostsSaidCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["GoodSaidCount"].ToString() != "")
                {
                    model.GoodSaidCount = Int32.Parse(ds.Tables[0].Rows[0]["GoodSaidCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WeiXin"].ToString() != "")
                {
                    model.WeiXin = ds.Tables[0].Rows[0]["WeiXin"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UsefulCount"].ToString() != "")
                {
                    model.UsefulCount = Int32.Parse(ds.Tables[0].Rows[0]["UsefulCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UMoney"].ToString() != "")
                {
                    model.UMoney = Int32.Parse(ds.Tables[0].Rows[0]["UMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserType"].ToString() != "")
                {
                    model.UserType = Int32.Parse(ds.Tables[0].Rows[0]["UserType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = Int32.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Creator"].ToString() != "")
                {
                    model.Creator = Int64.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Created"].ToString() != "")
                {
                    model.Created = System.DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modifier"].ToString() != "")
                {
                    model.Modifier = Int64.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modified"].ToString() != "")
                {
                    model.Modified = System.DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StuNo"].ToString() != "")
                {
                    model.StuNo = ds.Tables[0].Rows[0]["StuNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SelfID"].ToString() != "")
                {
                    model.SelfID = ds.Tables[0].Rows[0]["SelfID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ClassName"].ToString() != "")
                {
                    model.ClassName = ds.Tables[0].Rows[0]["ClassName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RolesId"].ToString() != "")
                {
                    model.RolesId = Int64.Parse(ds.Tables[0].Rows[0]["RolesId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Roles"].ToString() != "")
                {
                    model.Roles = ds.Tables[0].Rows[0]["Roles"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DepaId"].ToString() != "")
                {
                    model.DepaId = Int64.Parse(ds.Tables[0].Rows[0]["DepaId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DepaName"].ToString() != "")
                {
                    model.DepaName = ds.Tables[0].Rows[0]["DepaName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ImagesBlog"].ToString() != "")
                {
                    model.ImagesBlog = ds.Tables[0].Rows[0]["ImagesBlog"].ToString();
                }
                if (ds.Tables[0].Rows[0]["GoodCount"].ToString() != "")
                {
                    model.GoodCount = Int32.Parse(ds.Tables[0].Rows[0]["GoodCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ParentId"].ToString() != "")
                {
                    model.ParentId = Int64.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SysDegreeId"].ToString() != "")
                {
                    model.SysDegreeId = Int64.Parse(ds.Tables[0].Rows[0]["SysDegreeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SysDegreeName"].ToString() != "")
                {
                    model.SysDegreeName = ds.Tables[0].Rows[0]["SysDegreeName"].ToString();
                }

                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM Users ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" * ");
            strSql.Append(" FROM Users ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}

